package com.dt76.smallloanbackendservice.service.lhuaw.impl;

import com.dt76.smallloanbackendservice.mapper.lhuaw.AppPushMessageMapper;
import com.dt76.smallloanbackendservice.pojo.lhuaw.AppPushMessage;
import com.dt76.smallloanbackendservice.service.lhuaw.AppPushMessageService;
import com.dt76.smallloanbackendservice.utils.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AppPushMessageServiceImpl implements AppPushMessageService {

    @Autowired
    private AppPushMessageMapper appPushMessageMapper;
    @Override
    public List<AppPushMessage> qryAllApp() {
        return appPushMessageMapper.qryAllApp();
    }

    @Override
    public Page getAllAppPushMessage(int pageIndex, String pushTitle, String appPublisher) {
        Page page =new Page();
        page.setPageIndex(pageIndex);
        page.setTotalCount(appPushMessageMapper.qryConditionCountAppPushMessage(pushTitle,appPublisher));
        List<AppPushMessage> appPushMessageList = appPushMessageMapper.getConditionPageAllAppPushMessage((page.getPageIndex()-1)*page.getPageSize(),
                page.getPageSize(),pushTitle,appPublisher);
        System.out.println(appPushMessageList);
        page.setRows(appPushMessageList);
        return page;
    }

    @Override
    public void delApp(int appId) {
        appPushMessageMapper.deleteApp(appId);
    }
}
